/*
 * MedicationView.fx
 *
 * Created on Mar 11, 2010, 9:46:37 PM
 */

package GraphsWindowPackage.LabPackage;

import javafx.scene.Node;

import javafx.scene.shape.Line;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Text;
import javafx.scene.Group;
import javafx.util.Math;
import AlertSystem.Window;
import GraphsWindowPackage.LabMedNode;

/**
 * @author quang
 */

def timeLineStrokeWidth: Integer = 3;

//Categorical Lab Chart
public class CtgLabChart extends Window {

    public var ctgTimeSeq: Float[];
    public var ctgLabValSeq: String[];
    public var numPixPerTimeUnit: Number = 0;   //number of pixels per one time unit (day)
    public var startShownTime: Number = 0;

    function createPointSeq(ctgTimeSeq: Float[], ctgLabValSeq: String[]): LabMedNode[] {
        return
        for (i in [0..sizeof ctgTimeSeq - 1]) {
            LabMedNode {
                shape: Circle {
                    translateX: yLabelWidth
                    centerX: (ctgTimeSeq[i] - startShownTime) * this.numPixPerTimeUnit
                    centerY: 0
                    radius: dataPointRadius
                    fill: Color.BLACK
                    smooth: true
                }
                info: "{Math.round(Math.floor(ctgTimeSeq[i]))} days {Math.round ((ctgTimeSeq[i] - Math.floor(ctgTimeSeq[i])) * 24)} hours from the beginning of treatment period\n"
                        "Lab value: {ctgLabValSeq[i]}"
            }
        }
    }

    public override function create(): Node {
        if (ctgTimeSeq.isEmpty()) return null;

        def yLabel = Text {
                content: "Categ Values"
                wrappingWidth: yLabelWidth
            }

        def line = Line {
            translateX: yLabelWidth
            startX: 0, startY: 0
            endX: timeLineWidth, endY: 0
            strokeWidth: timeLineStrokeWidth
            stroke: Color.GRAY
            smooth: false
        }

        var pointSeq = bind createPointSeq(ctgTimeSeq, ctgLabValSeq);

        return Group { content: bind [yLabel, line, pointSeq] }
        
    }
}
